from flask import (session)


class FilterRecord:
    def __init__(self):
        self.filter_record = {}

    def getRecord(self, sheet):
        if 'filter_record' not in session.keys():
            session['filter_record'] = {}

        if sheet not in self.filter_record.keys():
            self.filter_record[sheet] = ['原始数据']
            session['filter_record'] = self.filter_record

        self.filter_record = session['filter_record']

        return self.filter_record[sheet]

    def setRecord(self, sheet, val):
        record = self.getRecord(sheet)

        record.append(val)

        session['filter_record'][sheet] = record

    def clearRecord(self, sheet):
        self.getRecord(sheet)
        session['filter_record'][sheet] = []


